﻿using System;
using System.Text.Json.Serialization;

namespace TowerCraneMonitorClient.NetClient.EventAlarm
{
    /// <summary>
    /// 报警事件信息
    /// </summary>
    public class EventMessage
    {
        /// <summary>
        /// 主键
        /// </summary>
        [JsonIgnore]
        public long Id { get; private set; }

        /// <summary>
        /// 动作类型
        /// </summary>
        public ActionType ActionType { get; set; }

        /// <summary>
        /// 报警级别
        /// </summary>
        public WarnLevel WarnLevel { get; set; }

        /// <summary>
        /// 报警类型
        /// </summary>
        public WarnType WarnType { get; set; }

        /// <summary>
        /// 力矩。当前力矩所占最大力矩的百分比，范围为0 - 255
        /// </summary>
        public float Force
        {
            get => force;
            set
            {
                if (value < 0 || value > 255)
                    throw new ArgumentOutOfRangeException(
                        nameof(Force),
                        "力矩所占最大力矩的百分比超出范围 0 - 255");
                force = value;
            }
        }
        float force;

        /// <summary>
        /// 转角。当前转角度为单位
        /// </summary>
        public float Angle { get; set; }

        /// <summary>
        /// 变幅。小车当前位置，以m为单位
        /// </summary>
        public float Extent { get; set; }

        /// <summary>
        /// 高度。吊钩当前高度，以m为单位
        /// </summary>
        public float Height { get; set; }

        /// <summary>
        /// 吊重。吊钩所掉重物的重量，以0.01吨为单位
        /// </summary>
        public float Weight { get; set; }


        /// <summary>
        /// 事件信息主体实体外键属性
        /// </summary>
        [JsonIgnore]
        public long EventAlarmId { get; private set; }

        /// <summary>
        /// 事件信息主体实体导航属性
        /// </summary>
        [JsonIgnore]
        public Entity EventAlarm { get; set; }
    }
}
